﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Telerik.Web.Mvc;
using FinancialManagement.Models;
using FinancialManagement.Models.Repository;

namespace FinancialManagement.Controllers
{
    public class GridController : Controller
    {
        BudgetRepository budgetRepository = new BudgetRepository();
        AccountRepository accountRepository = new AccountRepository();

        ///// <summary>
        ///// 显示添加项目预算明细信息的Window
        ///// </summary>
        ///// <param name="id"></param>
        ///// <returns></returns>
        //public ActionResult ShowAddWindow(string id)
        //{
        //    ViewBag.WindowTitle = "添加申报预算明细";
        //    ProjectTbaleDetails detail = new ProjectTbaleDetails();
        //    detail.ProjectID = id;
        //    return View(detail);
        //}

        ///// <summary>
        ///// 显示修改项目预算明细信息的Window
        ///// </summary>
        ///// <param name="id"></param>
        ///// <returns></returns>
        //public ActionResult ShowEditWindow(int id)
        //{
        //    ViewBag.WindowTitle = "更新申报预算明细";
        //    ProjectTbaleDetails detail = budgetRepository.GetDepBudgetProjectDetailByDSID(id);
        //    return View(detail);
        //}

        ///// <summary>
        ///// 插入项目预算明细信息
        ///// </summary>
        ///// <returns></returns>
        //public string InsertDepBudgetProjectDetail(ProjectTbaleDetails detail)
        //{
        //    var model = new ProjectTbaleDetails();
        //    if (TryUpdateModel(model))
        //    {
        //        model.Illustration = UploadController.FilePath;
        //        //The model is valid - insert the product.                
        //        var isOk = budgetRepository.InsertDepBudgetProjectDetail(model);
        //        if (isOk)
        //        {
        //            return SUCCESS;
        //        }
        //        return ERROR; 
        //    }
        //    return ERROR;
        //}

        ///// <summary>
        ///// 更新项目预算明细信息
        ///// </summary>
        ///// <param name="details"></param>
        ///// <returns></returns>
        //public string SaveDepBudgetProjectDetail(ProjectTbaleDetails details)
        //{
        //    var model = budgetRepository.GetDepBudgetProjectDetailByDSID(details.DSID);
        //    TryUpdateModel(model);
        //    var isOk = budgetRepository.UpdateDepBudgetProjectDetail(model);
        //    if (isOk)
        //    {
        //        return SUCCESS;
        //    }
        //    return ERROR;
        //}

        ///// <summary>
        ///// 删除项目预算明细信息
        ///// </summary>
        ///// <param name="id"></param>
        ///// <returns></returns>
        //[AcceptVerbs(HttpVerbs.Post)]
        //[GridAction]
        //public string DeleteDepBudgetProjectDetail(int id)
        //{
        //    var isOk = budgetRepository.DeleteDepBudgetProjectDetailByDSID(id);
        //    if (isOk)
        //    {
        //        return SUCCESS;
        //    }
        //    return ERROR;
        //}

        ///// <summary>
        ///// 加载id=Details的Grid
        ///// </summary>
        ///// <param name="projectID"></param>
        ///// <returns></returns>
        //[GridAction]
        //public ActionResult SelectionClientSide_ProjectDetails(string projectID) 
        //{
        //    projectID = projectID ?? "";
        //    return View(new GridModel(budgetRepository.GetDepBudgetProjectDetailByProjectId(projectID))); 
        //}
        
        ///// <summary>
        ///// 加载id=Project的Grid
        ///// </summary>
        ///// <returns></returns>
        //[GridAction]
        //public ActionResult SelectionClientSide_ProjectTables() 
        //{
        //    string depId = accountRepository.GetDepIdByUserName(User.Identity.Name);
        //    return View(new GridModel(budgetRepository.GetDepBudgetCollectionsByDepId(depId)));
        //}
    }
}
